import Server from './server';

class API extends Server {
    /**
     *  用途：上传图片
     *  @url https://elm.cangdu.org/v1/addimg/shop
     *  返回status为1表示成功
     *  @method post
     *  @return {promise}
     */
    async uploadImg(params = {}) {
        params.headers = {'Content-Type':'multipart/form-data'}
        try {
            let result = await this.axios('post', '/upload', params);
            if (result && result.status === 1) {
                return result;
            } else {
                let err = {
                    tip: '上传图片失败',
                    response: result,
                    data: params,
                    url: 'http://localhost:5656/',
                }
                throw err;
            }
        } catch (err) {
            throw err;
        }
    }
}

export default new API();